var n = 0, flag = true, JSONData = "";
var appdata = "", account = "", num = 0, total = 0, pagelen = 0, sum = 0.0, gmoney = "", money = 0.0;
var plxx = new Array();
var pltu = new Array();
var newsbox = $(".datalist");
var showtu = $(".showbigtu");
/*初始化*/
var counter = 1;
/*计数器*/
var pageStart = 0;
/*offset*/
var pageSize = 1;
/*size*/

/*首次加载*/
getData(pageStart, pageSize);

/*监听加载更多*/
$(document).on('click', '.js-load-more', function () {
    counter++;
    pageStart = counter * pageSize;

    getData(pageStart, pageSize);
});

function getData(offset, size) {
    $.ajax({
        url: "mysrlist",
        type: "POST",
        dataType: "JSON",
        data: {"form": counter},
        success: function (data) {

            $(".srsum").html("￥" + data.summon);

            /*使用for循环模拟SQL里的limit(offset,size)*/
            console.log(data)
            var mysr = data.Page.pageList;
            var monlist = data.moneylist;
            for (var o = 0; o < mysr.length; o++) {
                for (var i = 0; i < monlist.length; i++) {
                    if (o == i) {
                        console.log(o + "-" + i)
                        money = monlist[i]
                        console.log(money)
                    }
                }
                /* money*/

                appdata += "<a  class='aui-cells-cell'><div class='aui-cell-hd'><h4>" + mysr[o].orderTitle + "</h4><p>" + mysr[o].orderDate + "</p></div><span style='color:red;'>+" + money + "</span></a>"
                newsbox.html("")
                newsbox.append(appdata);
            }

            if (mysr.length == 0) {

                appdata = "<img style='position: relative;top: 90px;left: -60px;' src='/images/kong.png'>";
                newsbox.html("")
                newsbox.append(appdata);
            }

            /*隐藏more按钮*/
            if (data.Page.hasNextPage == false) {
                $(".js-load-more").hide();
            } else {
                $(".js-load-more").show();
            }
        },
        error: function (xhr, type) {

        }
    });
}

$(".back img").click(function () {

    location.href = "doindex"
})
